package com.sprinboot_vue.blog_springboot.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sprinboot_vue.blog_springboot.entity.Blog;
import com.sprinboot_vue.blog_springboot.mapper.BlogMapper;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.List;

/**
 * @author Thomas
 * @version 1.0
 * @date 2021/11/23 15:11
 */
@SpringBootTest
public class BlogHandler {
    @Autowired
    private BlogMapper blogMapper;
    
    @Test
    void findCountBlog(){
        int countBlog = blogMapper.findCountBlog();
        System.out.println(countBlog);
    }


    @Test
    //限定分类的情况下查询所有的分类!!!
    void FindALLTypeByDesc(){
        Page<Blog> page_1=new Page<>(1,5);
        List<Blog> blogs = blogMapper.FindALLTypeByDesc(page_1, "计算机");
        System.out.println(blogs);
    }

    @Test
    //限定分类的情况下查询相应分类的博客数量!!!
    void FindALLTypeByNumber(){
        int a = blogMapper.FindALLTypeByNumber("计算机");
        System.out.println(a);
    }

    @Test
    //限定标签的情况下查询相应标签的博客数量!!!
    void FindALLTagByNumber(){
        int a = blogMapper.FindALLTagByNumber("Java");
        System.out.println(a);
    }

    @Test
    //限定标签的情况下查询相应的博客!!!(分页)
    void FindAllTagBlog(){
        Page<Blog> page=new Page<>(1,5);
        List<Blog> java = blogMapper.FindALLTagByDesc(page, "Java");
        System.out.println(java);
    }
}
